package ui;

import java.awt.Graphics;
import config.GameConfig;

public class LayerPoint extends Layer {

	/**
	 * 分数最大位
	 */
	private static final int POINT_BIT = 5;
	
	/**
	 * 消行Y坐标
	 */
	private final int rmLineY;
	
	/**
	 * 经验值槽Y坐标
	 */
	public int expY;

	/**
	 * 升级所需消行数
	 */
	private static final int LEVEL_UP = GameConfig.getSystemConfig().getLevelUp();
	
	/**
	 * 分数Y坐标
	 */
	private final int pointY;
	
	/**
	 * 消行X坐标
	 */
	private final int comX;
	
	public LayerPoint(int x, int y, int w, int h) {
		super(x, y, w, h);
		//初始化共通X坐标
		this.comX = this.w - IMG_NUMBER_W * POINT_BIT - PADDING;
		//初始化分数Y坐标
		this.pointY = PADDING;
		//初始化消行Y坐标
		this.rmLineY = this.pointY + Img.POINT.getHeight(null) + PADDING;
		//初始化经验值槽Y坐标
		this.expY = this.rmLineY + Img.RMLINE.getHeight(null) + PADDING;
	}
	
	public void paint(Graphics g){
		this.createWindow(g);
		//绘制标题（分数）
		g.drawImage(Img.POINT, this.x + PADDING, this.y + pointY, null);
		this.drawNumLeftPad(comX, pointY, this.dto.getNowPoint(), POINT_BIT, g);
		//绘制标题（消行）
		g.drawImage(Img.RMLINE, this.x + PADDING, this.y + rmLineY, null);
		this.drawNumLeftPad(comX, rmLineY, this.dto.getNowRemoveLine(), POINT_BIT, g);
		//绘制值槽
		int rmLine = this.dto.getNowRemoveLine();
		this.drawRect(expY, "下一级", null, (double)(rmLine % 20) / (double)LEVEL_UP, g);
	}
}
